<?php
/**
 * Created by PhpStorm.
 * User: yyq
 * Date: 2017/3/10
 * Time: 14:59
 */

namespace Information\Model;


use Common\Model\CommonModel;

class InformationModel extends CommonModel
{

    public $types = array(
        array(
            'id' => '1',
            'name' => '案例分享',
            'type' => 'demo'
        ),
        array(
            'id' => '2',
            'name' => '国家政策',
            'type' => 'policy'
        ),
        array(
            'id' => '3',
            'name' => '行业现状',
            'type' => 'industry'
        ),
        array(
            'id' => '4',
            'name' => '企业信息',
            'type' => 'company'
        ),
        array(
            'id' => '5',
            'name' => '团队介绍',
            'type' => 'team'
        ),
        array(
            'id' => '6',
            'name' => '科普信息',
            'type' => 'science'
        ),
    );

    /**
     * 获取信息类型名称
     * @param $id
     * @return mixed
     */
    public function getType($id) {
        foreach($this->types as $k => $v) {
            if($v['id'] == $id) {
                return $v['name'];
            }
        }
    }

    /**
     * 根据类型返回数据库存储类型id
     * @param $string
     * @return int
     */
    public function getStringToType($string) {
        switch ($string) {
            case 'demo':
                return 1;
            break;
            case 'policy':
                return 2;
                break;
            case 'industry':
                return 3;
                break;
            case 'company':
                return 4;
                break;
            case 'team':
                return 5;
                break;
            case 'science':
                return 6;
                break;
            default:
                return '';
            break;
        }
    }
}